package br.ebula.apl.dao;

import java.sql.CallableStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import br.ebula.apl.dto.DTOLogin;

public class DAORealizaLogin extends DAOGenerico {

	DTOLogin dto;
	
	public void validaDados(DTOLogin dto) {
		try {
			
			this.dto = dto;
			
			ResultSet rs = executaProcedure("realiza_login",2);
			if (rs.next()) {
				dto.setUsuarioLogado();
			}
			
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}

	@Override
	void configuraParametros(CallableStatement cstmt) throws SQLException {
		 cstmt.setString(1, dto.getLogin().getLogin().toString());
		 cstmt.setString(2, dto.getLogin().getSenha().toString());
	}

}
